package com.fate.securecheckplatform.db;

import android.text.TextUtils;

import androidx.room.TypeConverter;

import com.fate.securecheckplatform.bean.TableForbiddenThing;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

import java.util.List;

/**
 * Author:   RandBII
 * DATE:   2020/1/10
 * Description:
 */
public class TableForbiddenThingCoverter {

    @TypeConverter
    public static String thingsToStr(List<TableForbiddenThing> thing) {
        if (thing == null) return null;
        return new GsonBuilder().create().toJson(thing);
    }


    @TypeConverter
    public static List<TableForbiddenThing> strToThings(String str) {
        if (TextUtils.isEmpty(str)) return null;
        return new GsonBuilder().create().fromJson(str, new TypeToken<List<TableForbiddenThing>>() {
        }.getType());
    }


}
